package tfmcbs.diagram.part;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.eclipse.gef.Tool;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteGroup;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeConnectionTool;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeCreationTool;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;

import tfmcbs.diagram.providers.ComponentBasedSystemElementTypes;

/**
 * @generated
 */
public class ComponentBasedSystemPaletteFactory {

	/**
	 * @generated
	 */
	public void fillPalette(PaletteRoot paletteRoot) {
		paletteRoot.add(createComponentBasedSystem1Group());
	}

	/**
	 * Creates "Component Based System" palette tool group
	 * @generated
	 */
	private PaletteContainer createComponentBasedSystem1Group() {
		PaletteGroup paletteContainer = new PaletteGroup(
				Messages.ComponentBasedSystem1Group_title);
		paletteContainer.setId("createComponentBasedSystem1Group"); //$NON-NLS-1$
		paletteContainer.add(createPrimitiveComponent1CreationTool());
		paletteContainer.add(createCompositeComponent2CreationTool());
		paletteContainer.add(createArtifact3CreationTool());
		paletteContainer.add(createInterface4CreationTool());
		paletteContainer.add(createProvidingport5CreationTool());
		paletteContainer.add(createRequiringPort6CreationTool());
		paletteContainer.add(createConnection7CreationTool());
		paletteContainer.add(createDependency8CreationTool());
		paletteContainer.add(createManifestation9CreationTool());
		paletteContainer.add(createUsage10CreationTool());
		paletteContainer.add(createRealization11CreationTool());
		paletteContainer.add(createGeneralization12CreationTool());
		paletteContainer.add(createDelegate13CreationTool());
		return paletteContainer;
	}

	/**
	 * @generated
	 */
	private ToolEntry createPrimitiveComponent1CreationTool() {
		ArrayList<IElementType> types = new ArrayList<IElementType>(2);
		types.add(ComponentBasedSystemElementTypes.PrimitiveComponent_2022);
		types.add(ComponentBasedSystemElementTypes.PrimitiveComponent_3019);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.PrimitiveComponent1CreationTool_title,
				Messages.PrimitiveComponent1CreationTool_desc, types);
		entry.setId("createPrimitiveComponent1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/PrimitiveComponentSmall.gif")); //$NON-NLS-1$
		entry.setLargeIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/PrimitiveComponentLarge.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createCompositeComponent2CreationTool() {
		ArrayList<IElementType> types = new ArrayList<IElementType>(2);
		types.add(ComponentBasedSystemElementTypes.CompositeComponent_2023);
		types.add(ComponentBasedSystemElementTypes.CompositeComponent_3020);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.CompositeComponent2CreationTool_title,
				Messages.CompositeComponent2CreationTool_desc, types);
		entry.setId("createCompositeComponent2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/CompositeComponentSmall.gif")); //$NON-NLS-1$
		entry.setLargeIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/CompositeComponentLarge.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createArtifact3CreationTool() {
		ArrayList<IElementType> types = new ArrayList<IElementType>(2);
		types.add(ComponentBasedSystemElementTypes.Artifact_3022);
		types.add(ComponentBasedSystemElementTypes.Artifact_2025);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Artifact3CreationTool_title,
				Messages.Artifact3CreationTool_desc, types);
		entry.setId("createArtifact3CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/ArtifactSmall.gif")); //$NON-NLS-1$
		entry.setLargeIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/ArtifactLarge.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createInterface4CreationTool() {
		ArrayList<IElementType> types = new ArrayList<IElementType>(2);
		types.add(ComponentBasedSystemElementTypes.Interface_3021);
		types.add(ComponentBasedSystemElementTypes.Interface_2024);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Interface4CreationTool_title,
				Messages.Interface4CreationTool_desc, types);
		entry.setId("createInterface4CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/InterfaceSmall.gif")); //$NON-NLS-1$
		entry.setLargeIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/InterfaceLarge.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createProvidingport5CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Providingport5CreationTool_title,
				Messages.Providingport5CreationTool_desc,
				Collections
						.singletonList(ComponentBasedSystemElementTypes.ProvidingPort_3014));
		entry.setId("createProvidingport5CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/ProvidingPortSmall.gif")); //$NON-NLS-1$
		entry.setLargeIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/ProvidingPortLarge.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createRequiringPort6CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.RequiringPort6CreationTool_title,
				Messages.RequiringPort6CreationTool_desc,
				Collections
						.singletonList(ComponentBasedSystemElementTypes.RequiringPort_3015));
		entry.setId("createRequiringPort6CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/RequiringPortSmall.gif")); //$NON-NLS-1$
		entry.setLargeIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/RequiringPortLarge.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createConnection7CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.Connection7CreationTool_title,
				Messages.Connection7CreationTool_desc,
				Collections
						.singletonList(ComponentBasedSystemElementTypes.Connection_4037));
		entry.setId("createConnection7CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/ConnectionSmall.gif")); //$NON-NLS-1$
		entry.setLargeIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/ConnectionLarge.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createDependency8CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.Dependency8CreationTool_title,
				Messages.Dependency8CreationTool_desc,
				Collections
						.singletonList(ComponentBasedSystemElementTypes.Dependency_4038));
		entry.setId("createDependency8CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/DependencySmall.gif")); //$NON-NLS-1$
		entry.setLargeIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/DependencyLarge.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createManifestation9CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.Manifestation9CreationTool_title,
				Messages.Manifestation9CreationTool_desc,
				Collections
						.singletonList(ComponentBasedSystemElementTypes.Manifestation_4039));
		entry.setId("createManifestation9CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/ManifestationSmall.gif")); //$NON-NLS-1$
		entry.setLargeIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/ManifestationLarge.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createUsage10CreationTool() {
		ArrayList<IElementType> types = new ArrayList<IElementType>(2);
		types.add(ComponentBasedSystemElementTypes.PrimitiveUsage_4050);
		types.add(ComponentBasedSystemElementTypes.PortUsage_4041);
		LinkToolEntry entry = new LinkToolEntry(
				Messages.Usage10CreationTool_title, null, types);
		entry.setId("createUsage10CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/UsageSmall.gif")); //$NON-NLS-1$
		entry.setLargeIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/UsageLarge.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createRealization11CreationTool() {
		ArrayList<IElementType> types = new ArrayList<IElementType>(2);
		types.add(ComponentBasedSystemElementTypes.PrimitiveRealization_4042);
		types.add(ComponentBasedSystemElementTypes.PortRealization_4043);
		LinkToolEntry entry = new LinkToolEntry(
				Messages.Realization11CreationTool_title, null, types);
		entry.setId("createRealization11CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/RealizationSmall.gif")); //$NON-NLS-1$
		entry.setLargeIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/RealizationLarge.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createGeneralization12CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.Generalization12CreationTool_title,
				null,
				Collections
						.singletonList(ComponentBasedSystemElementTypes.EntityExtends_4046));
		entry.setId("createGeneralization12CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/GeneralizationSmall.gif")); //$NON-NLS-1$
		entry.setLargeIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/GeneralizationLarge.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createDelegate13CreationTool() {
		ArrayList<IElementType> types = new ArrayList<IElementType>(2);
		types.add(ComponentBasedSystemElementTypes.ProvidingPortDelegate_4047);
		types.add(ComponentBasedSystemElementTypes.RequiringPortDelegate_4048);
		LinkToolEntry entry = new LinkToolEntry(
				Messages.Delegate13CreationTool_title,
				Messages.Delegate13CreationTool_desc, types);
		entry.setId("createDelegate13CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/DelegateSmall.gif")); //$NON-NLS-1$
		entry.setLargeIcon(ComponentBasedSystemDiagramEditorPlugin
				.findImageDescriptor("icons/DelegateLarge.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private static class NodeToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List<IElementType> elementTypes;

		/**
		 * @generated
		 */
		private NodeToolEntry(String title, String description,
				List<IElementType> elementTypes) {
			super(title, description, null, null);
			this.elementTypes = elementTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}

	/**
	 * @generated
	 */
	private static class LinkToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List<IElementType> relationshipTypes;

		/**
		 * @generated
		 */
		private LinkToolEntry(String title, String description,
				List<IElementType> relationshipTypes) {
			super(title, description, null, null);
			this.relationshipTypes = relationshipTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}
}
